package main

import (
	"fmt"
	"sort"
)

//#link: https://leetcode-cn.com/problems/h-index/
func main() {
	citations := []int{0, 1, 1}
	fmt.Println(hIndex(citations))
}

func hIndex(citations []int) (h int) {
	sort.Ints(citations)
	for i := len(citations) - 1; i >= 0 && citations[i] > h; i-- {
		h++
	}
	return
}
